﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace ConfigureNZBLoader
{
    public partial class AddRequest : Form
    {
        private string _Season;
        public string Season
        {
            get
            {
                return _Season;
            }
        }

        private string _Episode;
        public string Episode
        {
            get
            {
                return _Episode;
            }
        }

        public AddRequest()
        {
            InitializeComponent();
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.Cancel;
            Close();
        }

        private void btnOk_Click(object sender, EventArgs e)
        {
            uint dummy;
            if (rdSingle.Checked)
            {
                if (uint.TryParse(txtEpisode.Text, out dummy) && uint.TryParse(txtSeason.Text, out dummy))
                {
                    _Episode = txtEpisode.Text;
                    _Season = txtSeason.Text;
                }
            }
            else if (rdSeason.Checked)
            {
                if (uint.TryParse(txtSeason2.Text, out dummy))
                {
                    _Episode = "0";
                    _Season = txtSeason2.Text;
                }
            }
            else
            {
                _Episode = "0";
                _Season = "0";
            }

            DialogResult = DialogResult.OK;
            Close();
        }

        private void txtSeason_TextChanged(object sender, EventArgs e)
        {
            rdSingle.Checked = true;
        }

        private void txtSeason2_TextChanged(object sender, EventArgs e)
        {
            rdSeason.Checked = true;
        }
    }
}
